

#ifndef _DISKIO_DEFINED
#define _DISKIO_DEFINED

#ifdef __cplusplus
extern "C" {
#endif

#include "integer.h"

#define _USE_WRITE	1	
#define _USE_IOCTL	1	    
    

#define ATA		0
#define MMC		1
#define USB		2

#define SECTOR_SIZE     512
#define SECTOR_SHIFT    9



typedef BYTE	DSTATUS;


typedef enum {
	RES_OK = 0,		
	RES_ERROR,		
	RES_WRPRT,		
	RES_NOTRDY,		
	RES_PARERR		
} DRESULT;






DSTATUS disk_initialize (BYTE pdrv);
DSTATUS disk_status (BYTE pdrv);
DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);



#define STA_INIT        0x00    
#define STA_NOINIT		0x01	
#define STA_NODISK		0x02	
#define STA_PROTECT		0x04	





#define CTRL_SYNC			0	
#define GET_SECTOR_COUNT	1	
#define GET_SECTOR_SIZE		2	
#define GET_BLOCK_SIZE		3	
#define CTRL_ERASE_SECTOR	4	


#define CTRL_POWER			5	
#define CTRL_LOCK			6	
#define CTRL_EJECT			7	
#define CTRL_FORMAT			8	


#define MMC_GET_TYPE		10	
#define MMC_GET_CSD			11	
#define MMC_GET_CID			12	
#define MMC_GET_OCR			13	
#define MMC_GET_SDSTAT		14	


#define ATA_GET_REV			20	
#define ATA_GET_MODEL		21	
#define ATA_GET_SN			22	



#define CT_MMC		0x01		
#define CT_SD1		0x02		
#define CT_SD2		0x04		
#define CT_SDC		(CT_SD1|CT_SD2)	
#define CT_BLOCK	0x08		


#ifdef __cplusplus
}
#endif

#endif

